function validateInteger(data) {
		   var reg = /^\d+$/;
		   var num = data;
		   return reg.test(num);
		}


function validateFloat(data) {
	   var reg = /^(\+?((([0-9]+(\.)?)|([0-9]*\.[0-9]+))([eE][+-]?[0-9]+)?))$/;
	   var num = data;
	   return reg.test(num);
	}

function validateAddCourseForm(){

	var name = $('#NAME').val();
	var desc = $('#DESCRIPTION').val();
	var capacity = $('#CAPACITY').val();
	var points = $('#POINTS').val();
	var group = $('#GROUP_NUM').val();
	var day = $('#DAY').val();
	var start = $('#START_TIME').val();
	var end = $('#END_TIME').val();	
	

	$('#NAME_ERROR').text("");
	$('#DESC_ERROR').text("");
	$('#CAPACITY_ERROR').text("");
	$('#GROUP_ERROR').text("");
	$('#POINTS_ERROR').text("");
	$('#DAY_ERROR').text("");
	$('#START_EERROR').text("");
	$('#END_EERROR').text("");
	
	var error = true;
	


	if (name.length==0) {
		$('#NAME_ERROR').text("field cannot be empty");
		error = false;
	}

	if (desc.length==0) {
		$('#DESC_ERROR').text("field  cannot be empty");
		error = false;
	}

	if (capacity.length==0){
		$('#CAPACITY_ERROR').text("field  cannot be empty");
		error = false;
	}
	
	if (group.length==0){
		$('#GROUP_ERROR').text("field  cannot be empty");
		error = false;
	}
	
	if (points.length==0){
		$('#POINTS_ERROR').text("field  cannot be empty");
		error = false;
	}
	
	
	if (!validateInteger(capacity)){
		$('#CAPACITY_ERROR').text("must be a positive integer");
		error = false;
	}
	if (capacity.length>10){
		$('#CAPACITY_ERROR').text("must not exceed 10 chars");
		error = false;
	}
	
	if (!validateInteger(group)){
		$('#GROUP_ERROR').text("must be a positive integer");
		error = false;
	}
	if (group.length>10){
		$('#GROUP_ERROR').text("must not exceed 10 chars");
		error = false;
	}
	
	if (!validateFloat(points)){
		$('#POINTS_ERROR').text("must be a positive number");
		error = false;
	}
	if (points.length>10){
		$('#POINTS_ERROR').text("field  must not exceed 10 chars");
		error = false;
	}
	if (name.length>255) {
		$('#NAME_ERROR').text("field must not exceed 255 chars.");
		error = false;
	}

	if (desc.length>2000) {
		$('#DESC_ERROR').text("field must not exceed 2000 chars.");
		error = false;
	}

	return error;
}
